package com.itheima.chap04;

public class Gender {
    private int value;
    private String laber;

//    public Gender(int value, String laber) {
//        this.value = value;
//        this.laber = laber;
//    }

    private Gender(String laber, int value) {
        this.laber = laber;
        this.value = value;
    }

    private static final Gender MALE = new Gender("男", 0);
    private static final Gender FEMALE = new Gender("女", 1);

    public static Gender male(){
//        return new Gender("男", 0);
        return MALE;
    }

    public static Gender female(){
//        return new Gender("女", 1);
        return FEMALE;
    }

    public static Gender valueOf(int value){
        if(value != 0 && value != 1){
            throw new RuntimeException("性别参数不合法");
        }
        return value == 0 ? MALE : FEMALE;
    }


    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public String getLaber() {
        return laber;
    }

    public void setLaber(String laber) {
        this.laber = laber;
    }
}
